package cn.sunlight.mm.controller;

import cn.sunlight.framework.annotation.HmComponent;
import cn.sunlight.framework.annotation.HmRequestMapping;
import cn.sunlight.framework.annotation.HmSetter;
import cn.sunlight.mm.base.BaseController;
import cn.sunlight.mm.entity.Result;
import cn.sunlight.mm.pojo.Company;
import cn.sunlight.mm.service.CompanyService;
import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author sunlight
 * @description: 公司业务控制器
 * @date 2021/5/21
 * @Version v1.0
 */
@Slf4j
@HmComponent
public class CompanyController extends BaseController {

    @HmSetter("companyService")
    CompanyService companyService;

    /**
     * 获取所有公司业务数据
     * @param request
     * @param response
     * @throws Exception
     */
    @HmRequestMapping("/company/findListAll")
    public void findListAll (HttpServletRequest request, HttpServletResponse response) throws Exception {
        try {
            List<Company> companyList=companyService.findListAll();
            printResult(response,new Result(true,"查询成功",companyList));
        }catch (RuntimeException e){
            e.printStackTrace();
            log.error("",e);
            printResult(response,new Result(false,"查询失败"+e.getMessage()));
        }
    }

}
